package org.dromara.oce.controller.inner;

import cn.dev33.satoken.annotation.SaIgnore;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.web.core.BaseController;
import org.dromara.oce.domain.bo.OceAdvertiserReferralRelationBo;
import org.dromara.oce.mapper.OceAdvertiserReferralRelationMapper;
import org.dromara.oce.service.OceAdvertiserReferralRelationService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 推广链接-广告主关联
 * @desc:
 * @author: hhl
 * @date：2025/6/24 18:24
 * @module 对内接口
 */
@SaIgnore
@RequiredArgsConstructor
@RestController
@RequestMapping("/inner/referralRelation")
public class OceAdvertiserReferralInnerController extends BaseController {

    private final OceAdvertiserReferralRelationMapper oceAdvertiserReferralRelationMapper;
    private final OceAdvertiserReferralRelationService oceAdvertiserReferralRelationService;

    /**
     * 获取巨量启用的链接ID
     */
    @GetMapping("/getReferralLinkIdList")
    public List<Long> getReferralLinkIdList(@RequestParam("referralLinkType") Integer referralLinkType) {
        return oceAdvertiserReferralRelationMapper.getReferralLinkIdList(referralLinkType);
    }

    /**
     * 获取巨量所有链接
     */
    @GetMapping("/getAllReferralLinkIdList")
    public List<Long> getAllReferralLinkIdList(@RequestParam("referralLinkType") Integer referralLinkType){
        return oceAdvertiserReferralRelationMapper.getAllReferralLinkIdList(referralLinkType);
    }


    /**
     * 新增推广链接-广告主关联
     */
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody OceAdvertiserReferralRelationBo bo) {
        return toAjax(oceAdvertiserReferralRelationService.insertByBo(bo));
    }

}
